import { createRouter, createWebHistory } from 'vue-router'
import Login from '@/views/Login/index.vue'
import Layout from '@/views/Layout/index.vue'
import Home from '@/views/Home/index.vue'
import Category from '@/views/Category/index.vue'
import SubCategory from '@/views/SubCategory/index.vue'
import Detail from '@/views/Detail/index.vue'
import CartList from '@/views/CartList/index.vue'
import CheckOut from '@/views/CheckOut/index.vue'
import Pay from '@/views/Pay/index.vue'
import payBack from '@/views/Pay/payBack.vue'
import Search from '@/views/Search/index.vue'
import User from '@/views/User/index.vue'
import Undo from '@/views/Undo/index.vue'
import Order from '@/views/User/components/Order.vue'
import Collect from '@/views/User/components/Collect.vue'
import Control from '@/views/Control/index.vue'
import GoodsManage from '@/views/Control/components/GoodsManage.vue'
import UserManage from '@/views/Control/components/UserManage.vue'
import CouponManage from '@/views/Control/components/CouponManage.vue'
import OrderManage from '@/views/Control/components/OrderManage.vue'
import BannerManage from '@/views/Control/components/BannerManage.vue'
import Dashboard from '@/views/Control/components/Dashboard.vue'
import Coupon from '@/views/Home/components/Hot/coupon.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: Layout,
      children: [
        {
          path: '',  //默认访问页,至为空
          component: Home
        },
        {
          path: 'category/:id',
          component: Category
        },
        {
          path: 'category/sub/:id',
          component: SubCategory
        },
        {
          path: 'detail/:id',
          component: Detail
        },
        {
          path: '/cartList',
          component: CartList
        },
        {
          path: '/checkout',
          component: CheckOut
        },
        {
          path: '/pay',
          component: Pay
        },
        {
          path: '/paycallback',
          component: payBack
        },
        {
          path: '/search/:keyword',
          component: Search
        },
        {
          path: '/user',
          component: User
        },
        {
          path: '/category/discount',
          component: Undo,
        },
        {
          path: '/category/anthor',
          component: Undo
        },
        {
          path: '/category/brand',
          component: Undo
        },
        {
          path: '/category/album',
          component: Undo
        },
        {
          path: '/order',
          component: Order
        },
        {
          path: '/collect',
          component: Collect
        },
        {
          path: '/control',
          component: Control,
          children: [
            {
              path: '',
              component: Dashboard
            },
            {
              path: 'goodsManage',
              component: GoodsManage
            },
            {
              path: 'userManage',
              component: UserManage
            },
            {
              path: 'couponManage',
              component: CouponManage
            },
            {
              path: 'orderManage',
              component: OrderManage
            },
            {
              path: 'bannerManage',
              component: BannerManage
            },
          ]
        },
        {
          path: '/hot/4',
          component: Coupon
        },
        {
          path: '/hot/1',
          component: Undo
        },
        {
          path: '/hot/2',
          component: Undo
        },
        {
          path: '/hot/3',
          component: Undo
        }
      ]
    },
    {
      path: '/login',
      component: Login
    }
  ],
  //路由滚动定制行为
  scrollBehavior() {
    return {
      top: 0
    }
  }
})

export default router
